Change Texture2D::fill to be non-mutable#549
Conversation
|
Sorry for the really really late reply 😬 I think I was just being a bit idealistic and wanted functions that mutated something to be mutable so you don't accidentally edit something and it follows the Rust ideology. I think it's a nice idea, but it's hard to do in practice. For example, the render targets are usually used for writing, hence it's mutable to create a render target, but you can also use them for reading back to the CPU, so in that case it should be non-mutable. And your example with generating mip maps should also take a mutable reference, but since it's not enforced by the compiler, I didn't see it. So I think I'm going to change all cases of |
|
Changed the rest of the texture functions here |
|
Thanks a lot for the detailed explanations 👍 |
This PR changes
Texture2D::fillto be non-mutable, so that one can change a texture's contents through a materialTexture2DRef(which is behind anArc). I'm using this to display my webcam stream on a textured quad.It's unclear to me why the method currently takes a mutable ref to self since all the side-effects are on the GPU (just like
generate_mip_maps, which is non-mutable), so feel free to enlighten me on this point :)Best regards,